package ly.sjun.design.abstract_factory_pattern;

import ly.sjun.design.abstract_factory_pattern.factory.BiscuitFactory;
import ly.sjun.design.abstract_factory_pattern.factory.FruitFactory;
import ly.sjun.design.abstract_factory_pattern.factory.SugarFactory;

/**
 * @ClassName: FoodProducer
 * @Author: ly
 * @Date: 2023/1/4-11:14
 * @Description 生产商
 **/
public class FoodProducer {

    public static AbstractFoodFactory getFactory(String food) {
        if (food == null || "".equals(food)) {
            return null;
        }
        if (food.equalsIgnoreCase("fruit")) {
            return new FruitFactory();
        } else if (food.equalsIgnoreCase("biscuit")) {
            return new BiscuitFactory();
        } else if (food.equalsIgnoreCase("sugar")) {
            return new SugarFactory();
        }
        else
            return null;
    }

}
